package com.example.schedulemanager.database;

import android.content.Context;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

import com.example.schedulemanager.model.Schedule;

@Database(entities = {Schedule.class}, version = 1, exportSchema = false)
public abstract class ScheduleDatabase extends RoomDatabase {
    
    public abstract ScheduleDao scheduleDao();
    
    private static volatile ScheduleDatabase INSTANCE;
    
    public static ScheduleDatabase getDatabase(final Context context) {
        if (INSTANCE == null) {
            synchronized (ScheduleDatabase.class) {
                if (INSTANCE == null) {
                    INSTANCE = Room.databaseBuilder(
                            context.getApplicationContext(),
                            ScheduleDatabase.class,
                            "schedule_database"
                    ).build();
                }
            }
        }
        return INSTANCE;
    }
} 